package com.infore.water.controller;

import com.infore.water.service.DataService;
import com.infore.water.util.ListObject;
import com.infore.water.util.ResponseUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.text.ParseException;

/**
 * @author :wk
 */
@RestController
public class StatisticsControl {

    @Autowired
    private DataService dataService;

    /**
     * 获取监测点分析数据
     * @param stationString 监测点id字符串逗号隔开
     * @param dataType 数据类型
     * @param startTime 开始时间
     * @param endTime 结束时间
     * @return ListObject
     */
    @RequestMapping("/getStationAnalyse")
    public ListObject getStationAnalyse(@RequestParam(value = "stationString")String stationString,
                                        @RequestParam(value = "dataType")String dataType,
                                        @RequestParam(value = "startTime")String startTime,
                                        @RequestParam(value = "endTime")String endTime){
        try {
            return ResponseUtil.queryListObject(dataService.getStationAnalyse(stationString,startTime,endTime,dataType),"获取多站分析成功");
        } catch (ParseException e) {
            e.printStackTrace();
            return ResponseUtil.error();
        }
    }
}
